package com.hbnu.service;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class SendThread implements Runnable{
    private Socket socket;
    public SendThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        Scanner scanner = new Scanner(System.in);
        try {
            PrintWriter out = new PrintWriter(socket.getOutputStream(),true);
        while (true){
                String content=scanner.nextLine();
                out.println(content);
                if (content.equals("esc")) {
                    System.exit(0);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Thread thread =Thread.currentThread();
            thread.stop();
        }

    }
}
